//
//  MenuTableViewCell.m
//  吃喝玩乐一起嗨
//
//  Created by CEZ on 14-10-15.
//  Copyright (c) 2014年 CEZ. All rights reserved.
//

#import "MenuTableViewCell.h"

@implementation MenuTableViewCell


- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        [self topMenuButton];
        [self belowMenuButton];
        [self pageControll];
    }
    return self;

    
}
- (void)topMenuButton
{
    for (int i = 0; i < 4; i++) {
        _topButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _topButton.frame = CGRectMake(95 * i + 10, 10, 70, 70);
        [_topButton setBackgroundImage:[UIImage imageNamed:[NSString stringWithFormat:@"HomePageMenu1%d.png", i + 1]] forState:UIControlStateNormal];
        [self.contentView addSubview:_topButton];
    }
}
- (void)belowMenuButton
{
    self.scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 90, 375, 100)];
    _scrollView.pagingEnabled = YES;
    _scrollView.delegate = self;
    [_scrollView setContentSize:CGSizeMake(1125, 40)];
    [_scrollView setShowsHorizontalScrollIndicator:NO];
    [self.contentView addSubview:_scrollView];
    [_scrollView release];
    for (int i = 0; i < 10; i++) {
        _belowButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _belowButton.frame = CGRectMake(95 * i + 10, 10, 70, 70);
        [_belowButton setBackgroundImage:[UIImage imageNamed:[NSString stringWithFormat:@"HomePageMenu2%d.png", i + 1]] forState:UIControlStateNormal];
        [self.scrollView addSubview:_belowButton];
    }
}
//jkkljkljkl
//diyicishangchuan
- (void)pageControll
{
    self.pageControl = [[UIPageControl alloc]initWithFrame:CGRectMake(0, 190, 50, 10)];
    _pageControl.numberOfPages = 3;
    _pageControl.currentPageIndicatorTintColor = [UIColor colorWithRed:255 / 255.0 green:104 / 255.0 blue:99 / 255.0 alpha:1.0];
    _pageControl.pageIndicatorTintColor = [UIColor lightGrayColor];
    [_pageControl addTarget:self action:@selector(pageAction) forControlEvents:UIControlEventValueChanged];
    [self.contentView addSubview:_pageControl];
    [_pageControl release];
}
- (void)pageAction
{
    [_scrollView setContentOffset:CGPointMake(_pageControl.currentPage * 200, 0) animated:YES];
}
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
    _pageControl.currentPage = scrollView.contentOffset.x / 375;
}

- (void)awakeFromNib {
    // Initialization code
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
